Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Latest commit

 

History

History
24 lines (21 loc) · 767 Bytes

3.8.2 - Coroutine/MySQL->connect.md

File metadata and controls

24 lines (21 loc) · 767 Bytes

Coroutine\MySQL->connect

建立MySQL连接

bool connect(array $serverInfo)
  • $serverInfo:参数以数组形式传递
[
	'host' => 'MySQL IP地址',
	'user' => '数据用户',
	'password' => '数据库密码',
	'database' => '数据库名',
	'port'    => 'MySQL端口 默认3306 可选参数',
	'timeout' => '建立连接超时时间',
	'charset' => '字符集',
	'strict_type' => false, //开启严格模式,返回的字段将自动转为数字类型
	'fetch_mode' => true, //开启fetch模式, 可与pdo一样使用fetch/fetchAll逐行或获取全部结果集(4.0版本以上)
]
  • 返回值:连接建立成功返回true,否则返回false
  • timeout选项,仅影响connect超时时间,不影响queryexecute方法